package com.starblink.login.changeboundemail.verifyemail.ui

import com.alibaba.android.arouter.facade.annotation.Route
import com.starblink.basic.route.RoutePage
import com.starblink.android.basic.base.activity.BaseTVMActivity
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.starblink.android.basic.ext.click
import com.starblink.android.basic.user.login.LoginManager
import com.starblink.basic.style.title.OnTitleBarListener
import com.starblink.basic.style.title.TitleBar
import com.starblink.basic.util.ActivityStackManage
import com.starblink.login.databinding.ActivityChangeBoundEmailVerifyEmailBinding

/**
 * 修改绑定邮箱-验证邮箱
 */
@Route(path = RoutePage.Login.CHANGE_BOUND_EMAIL_VERIFY_EMAIL)
class ChangeBoundEmailVerifyEmailActivity :
    BaseTVMActivity<ActivityChangeBoundEmailVerifyEmailBinding, ChangeBoundEmailVerifyEmailVM>() {
    @Autowired(name = LoginManager.KEY_EMAIL)
    @JvmField
    var email: String = ""

    override fun initViewBinding(): ActivityChangeBoundEmailVerifyEmailBinding =
        ActivityChangeBoundEmailVerifyEmailBinding.inflate(layoutInflater)

    override fun initView() {
        super.initView()
        viewBinding.titleBar.setOnTitleBarListener(object : OnTitleBarListener {
            override fun onLeftClick(titleBar: TitleBar?) {
                finish()
            }
        })

        viewBinding.tvEmail.text = email

        viewBinding.btnActivateNow.click {
            viewModel.updateEmail(email)
        }

        viewBinding.btnActivateLater.click {
            // 返回MainActivity
            ActivityStackManage.toMainActivity()
        }
    }

    override fun initObservable() {
        super.initObservable()
    }
}